//
//  JXTabbarVC.m
//  JXAddressApp
//
//  Created by zhhw_home on 2018/10/25.
//  Copyright © 2018年 zhhw_home. All rights reserved.
//

#import "JXTabbarVC.h"
#import "JXHomeWebViewController.h"
#import "JXAddressDynamicPageViewController.h"
#import "JXBusinessTabViewController.h"
#import "JXMeTabViewController.h"
#import "UIColor+QMUI.h"
#import <QMUIKit/UIImage+QMUI.h>
#import "JXHomeViewController.h"

@interface JXTabbarVC ()

@end

@implementation JXTabbarVC

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    self.automaticallyAdjustsScrollViewInsets = NO;
}
    
- (void)initTabbar:(NSInteger)type
{
    _flag = type;
    self.tabBar.tintColor = [UIColor qmui_colorWithHexString:@"#333333"];
    
    UIViewController *homeVC = nil;
    
    if (_flag == 2) {
        homeVC = [JXHomeViewController new];
        homeVC.tabBarItem.selectedImage = [[UIImage imageNamed:@"tabbar_map"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        homeVC.tabBarItem.image = [UIImage imageNamed:@"tabbar_map_unselected"];
        homeVC.tabBarItem.title = @"地名查询";
    }
    else {
        homeVC = [JXHomeWebViewController new];
        homeVC.tabBarItem.selectedImage = [[UIImage imageNamed:@"tabbar_map"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        homeVC.tabBarItem.image = [UIImage imageNamed:@"tabbar_map_unselected"];
        homeVC.tabBarItem.title = @"地名查询";
    }

    JXAddressDynamicPageViewController *addressVC = [[JXAddressDynamicPageViewController alloc] init];
    addressVC.tabBarItem.selectedImage = [[UIImage imageNamed:@"tabbar_showplace"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    addressVC.tabBarItem.image = [UIImage imageNamed:@"tabbar_showplace_unselected"];
    addressVC.tabBarItem.title = @"地名动态";
    
    JXBusinessTabViewController *businessVC = [[JXBusinessTabViewController alloc] init];
    businessVC.tabBarItem.selectedImage = [[UIImage imageNamed:@"tabbar_business_selected"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    businessVC.tabBarItem.image = [UIImage imageNamed:@"tabbar_business"];
    businessVC.tabBarItem.title = @"民政业务";

    JXMeTabViewController *meVC = [[JXMeTabViewController alloc] init];
    meVC.tabBarItem.selectedImage = [[UIImage imageNamed:@"tabbar_me_unselected"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    meVC.tabBarItem.image = [UIImage imageNamed:@"tabbar_me"];
    meVC.tabBarItem.title = @"公众互动";
    
    QMUINavigationController *navigationVC0 = [[QMUINavigationController alloc] initWithRootViewController:homeVC];
    QMUINavigationController *navigationVC1 = [[QMUINavigationController alloc] initWithRootViewController:addressVC];
    QMUINavigationController *navigationVC2 = [[QMUINavigationController alloc] initWithRootViewController:businessVC];
    QMUINavigationController *navigationVC3 = [[QMUINavigationController alloc] initWithRootViewController:meVC];
    
    
    navigationVC1.navigationBar.hidden = YES;
    navigationVC2.navigationBar.hidden = YES;
    navigationVC3.navigationBar.hidden = YES;
    
    self.viewControllers = @[navigationVC0, navigationVC1, navigationVC2, navigationVC3];
    
    UIImage *image = [UIImage qmui_imageWithColor:[UIColor whiteColor]];
    [self.tabBar setBackgroundImage: image];

//
//    self.tabBar.translucent = NO;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
